package com.mql.springcloud.controller;


import com.example.cloudapicommons.entity.CommonResult;
import com.example.cloudapicommons.entity.PaymentEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class ConsumerController {
    public static final String PAYMENT_URL="http://CLOUD-PAYMENT-SERVICE";
@Autowired
private RestTemplate restTemplate;

@PostMapping("/consumer/payment/save")
public CommonResult<PaymentEntity> save(@RequestBody PaymentEntity paymentEntity){

    return restTemplate.postForObject(PAYMENT_URL+"/maQingLin/save",paymentEntity,CommonResult.class);
}

@GetMapping("/consumer/payment/get/{id}")
public CommonResult<PaymentEntity> getPayment(@PathVariable("id")Integer id){
    return restTemplate.getForObject(PAYMENT_URL+"/maQingLin/get/"+id,CommonResult.class);
}
}
